import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Solution solution = new Solution();
        String s = scanner.next();
        int t = scanner.nextInt();

        System.out.println(solution.lengthAfterTransformations(s, t));
    }
}

class Solution {
    private static final int mod=1000000007;
    public int lengthAfterTransformations(String s, int t) {
        int res=0;
        int[] cnt=new int[26];
        for(char x:s.toCharArray()){
            ++cnt[x-'a'];
            System.out.println(x + ":" + cnt[x-'a']);
        }

        for(int i = 0; i < t; i++){
            int[] arr=new int[26];
            arr[0]=cnt[25];
            arr[1]=(cnt[0]+cnt[25])%mod;
            for(int j=2;j<26;j++){
                arr[j]=cnt[j-1];
            }
            cnt=arr;
        }
        for(int i=0;i<26;i++){
            res=(res+cnt[i])%mod;
        }
        return res;
    }
}
